package com.example.pinkcat.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.recyclerview.widget.RecyclerView;

import com.example.pinkcat.R;
import com.example.pinkcat.activity.FansFollowPage;
import com.example.pinkcat.activity.Userpage;
import com.example.pinkcat.api.entity.Fankeep;

import java.util.ArrayList;
import java.util.List;

public class Wode_FankeepAdapter extends RecyclerView.Adapter<Wode_FankeepAdapter.ViewHolder> {

    public Context context;

    public List<Fankeep> fankeepMsgList = new ArrayList<>();

    public void addFanKeep(List<Fankeep> fankeepMsgList){
        this.fankeepMsgList = fankeepMsgList;
        notifyDataSetChanged();
    }

    public Wode_FankeepAdapter(Context context){
        this.context =context;
    }

    public class ViewHolder extends RecyclerView.ViewHolder{

        public TextView wode_btn1_dt_num;
        public TextView wode_btn2_keep_num;
        public TextView wode_btn3_fan_num;

        public View wode_btn1;
        public View wode_btn2;
        public View wode_btn3;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            wode_btn1_dt_num = itemView.findViewById(R.id.wode_tv_dongtai_num);
            wode_btn2_keep_num = itemView.findViewById(R.id.wode_tv_guanzhu_num);
            wode_btn3_fan_num = itemView.findViewById(R.id.wode_tv_fensi_num);

            wode_btn1 = itemView.findViewById(R.id.wode_bar_1_btn);
            wode_btn2 = itemView.findViewById(R.id.wode_bar_2_btn);
            wode_btn3 = itemView.findViewById(R.id.wode_bar_3_btn);




        }
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view;
        view = LayoutInflater.from(context).inflate(R.layout.fragment_wode,parent,false);
        return new Wode_FankeepAdapter.ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {


        //动态
        holder.wode_btn1_dt_num.setText(String.valueOf(fankeepMsgList.get(position).getMoving()));
        holder.wode_btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, Userpage.class);
                intent.putExtra("isCollectPage",false);
                context.startActivity(intent);
            }
        });

        //关注
        holder.wode_btn2_keep_num.setText(String.valueOf(fankeepMsgList.get(position).getKeep()));
        holder.wode_btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, FansFollowPage.class);
                intent.putExtra("isFansPage",false);
                context.startActivity(intent);
            }
        });

        //粉丝
        holder.wode_btn3_fan_num.setText(String.valueOf(fankeepMsgList.get(position).getFan()));
        holder.wode_btn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, FansFollowPage.class);
                intent.putExtra("isFansPage",true);
                context.startActivity(intent);
            }
        });

    }

    @Override
    public int getItemCount() {
        return 0;
    }


}
